import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import {rules} from '/@/utils/helper/validator';
import {render} from '/@/utils/common/renderUtils';
import {getWeekMonthQuarterYear} from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
	{
		title: '充电开始时间',
		align: 'center',
		dataIndex: 'beginTime',
	},
	{
		title: '充电结束时间',
		align: 'center',
		dataIndex: 'endTime',
	},
	{
		title: '车辆VIN',
		align: 'center',
		dataIndex: 'vin',
	},
	{
		title: '充电电量(度)',
		align: 'center',
		dataIndex: 'capacity',
	},
	{
		title: '充电开始soc(%)',
		align: 'center',
		dataIndex: 'startSoc',
	},
	{
		title: '充电结束soc(%)',
		align: 'center',
		dataIndex: 'endSoc',
	},
	{
		title: '停机原因',
		align: 'center',
		dataIndex: 'stopReason',
	},
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
		field: 'begin',
		component: 'DatePicker',
		label: '充电日期',
		componentProps: {
			//日期格式化
			format: 'YYYY/MM/DD',
			valueFormat: 'YYYY/MM/DD',
			//范围文本描述用集合
		},
		colProps: {
			span: 6,
		},
	},
	{
		field: 'end',
		component: 'DatePicker',
		label: '充电日期',
		componentProps: {
			//日期格式化
			valueFormat: 'YYYY/MM/DD',
			format: 'YYYY/MM/DD',
			//范围文本描述用集合
		},
		colProps: {
			span: 6,
		},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
	{
		label: '运营商名称',
		field: 'name',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入运营商名称!'}];
		},
	},
	{
		label: '运营商简称',
		field: 'shortName',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [
				{required: true, message: '请输入运营商简称!'},
				{pattern: '/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/', message: '不符合校验规则!'},
			];
		},
	},
	{
		label: '经营区域',
		field: 'operatingArea',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入经营区域!'}];
		},
	},
	{
		label: '统一社会信用代码',
		field: 'socialCreditCode',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入统一社会信用代码!'}];
		},
	},
	{
		label: '充电站数量',
		field: 'chargingStationCount',
		component: 'InputNumber',
		dynamicRules: ({model, schema}) => {
			return [{required: false}, {pattern: /^-?\d+$/, message: '请输入整数!'}];
		},
	},
	{
		label: '装机总功率（万千瓦）',
		field: 'totalPower',
		component: 'InputNumber',
		dynamicRules: ({model, schema}) => {
			return [{required: false}, {pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'}];
		},
	},
	{
		label: '联系人',
		field: 'contactPerson',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入联系人!'}];
		},
	},
	{
		label: '联系电话',
		field: 'contactPhone',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [
				{required: true, message: '请输入联系电话!'},
				{pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
			];
		},
	},
	{
		label: '创建时间',
		field: 'createTime',
		component: 'DatePicker',
		componentProps: {
			valueFormat: 'YYYY-MM-DD',
		},
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入创建时间!'}];
		},
	},
	{
		label: '运营商Logo URL',
		field: 'logo',
		component: 'JImageUpload',
		componentProps: {
			fileMax: 0,
		},
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入运营商Logo URL!'}];
		},
	},
	{
		label: '注册地址',
		field: 'registeredAddress',
		component: 'Input',
		dynamicRules: ({model, schema}) => {
			return [{required: true, message: '请输入注册地址!'}];
		},
	},
	{
		label: '运营商状态（0:启用, 1:停用）',
		field: 'status',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: 'operatorStatus',
		},
	},
	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false,
	},
];

// 高级查询数据
export const superQuerySchema = {
	name: {title: '运营商名称', order: 0, view: 'text', type: 'string'},
	shortName: {title: '运营商简称', order: 1, view: 'text', type: 'string'},
	operatingArea: {title: '经营区域', order: 2, view: 'text', type: 'string'},
	socialCreditCode: {title: '统一社会信用代码', order: 3, view: 'text', type: 'string'},
	chargingStationCount: {title: '充电站数量', order: 4, view: 'number', type: 'number'},
	totalPower: {title: '装机总功率（万千瓦）', order: 5, view: 'number', type: 'number'},
	contactPerson: {title: '联系人', order: 6, view: 'text', type: 'string'},
	contactPhone: {title: '联系电话', order: 7, view: 'text', type: 'string'},
	createTime: {title: '创建时间', order: 8, view: 'date', type: 'string'},
	logo: {title: '运营商Logo URL', order: 9, view: 'image', type: 'string'},
	registeredAddress: {title: '注册地址', order: 10, view: 'text', type: 'string'},
	status: {
		title: '运营商状态（0:启用, 1:停用）',
		order: 11,
		view: 'number',
		type: 'number',
		dictCode: 'operatorStatus',
	},
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
	// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
	return formSchema;
}
